HaskellのError Handling
Haskellの例外処理
safe-exceptionsパッケージ
exceptionsパッケージ
mtlのControl.Monad.Except
2016年では主流 ref
MonadErrorモナド
ExceptTモナド変換子
Exceptモナド
http://koba-e964.hatenablog.com/entry/2014/06/17/004011
https://tnomura9.exblog.jp/27625221/
https://tnomura9.exblog.jp/27623958/
参考記事
http://syocy.hatenablog.com/entry/2016/07/02/174426
enclosed-exceptionsパッケージ
https://hackage.haskell.org/package/enclosed-exceptions
https://www.schoolofhaskell.com/user/snoyberg/general-haskell/exceptions/catching-all-exceptions
try節内の例外のみをcatchする
exceptionalパッケージ
Haskell標準のライブラリ
Control.Exception
docs
例外モジュールがIO型に依存しているので扱いづらいらしい
標準だが今はあまり使わないっぽい
参考記事
https://qiita.com/7shi/items/73e534c47bbebc71b37e#例外
Control.Monad.Error
http://hackage.haskell.org/package/mtl-1.1.0.2/docs/Control-Monad-Error.html
ErrorT
ErrorTモナド変換子を使うと
type Eval2 a = ErrorT String Identity a
Stringでエラーの状態を示す
ここではエラーメッセージを表示するだけなのでStringだが、
コードの位置やタイムスタンプを示す型にもできる
https://tnomura9.exblog.jp/19486322/
http://hackage.haskell.org/package/mtl-1.1.0.2/docs/Control-Monad-Error.html
エラーメッセージ
https://anthony.noided.media/blog/haskell/programming/2020/05/14/haskell-errors.html
@GabriellaG439: 4 types of Haskell exceptions:
* Checked+Impure: ExceptT
* Unchecked+Impure: IO
* Checked+Pure: Either
* Unchecked+Pure: BAD (not in type)
https://qiita.com/rinse_/items/596cc07242aef880cf81
MonadThrow型クラス
https://anthony.noided.media/blog/haskell/programming/2020/05/14/haskell-errors.html
https://well-typed.com/blog/2020/06/fix-ing-regular-expressions/
https://gist.github.com/maksbotan/d358b5ff6081c5d5a94de8d32bbe098c
https://ryota-ka.hatenablog.com/entry/2020/12/20/000000
https://taylor.fausak.me/2021/04/03/default-exception-handler-in-haskell/